﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <td class="formTitle"><span class="required">*</span>收费大类：</td>
                <td class="formValue formDdlSelectorTd">
                    <select class="form-control required" id="dlCode" name="dlCode">
                        <option value="">==请选择==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="formTitle">收费项目：</td>
                <td class="formValue">
                    <input id="sfxmName" name="sfxmName" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">项目固定成本：</th>
                <td class="formValue">
                    <input id="xmgdcb" name="xmgdcb" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">比例：</td>
                <td class="formValue">
                    <input id="bl" name="bl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">固定金额：</th>
                <td class="formValue">
                    <input id="blhgdje" name="blhgdje" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">备注：</th>
                <td class="formValue">
                    <textarea id="bz" name="bz" class="form-control" style="height: 60px;"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">状态：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.najax({
                url: "/KPI/MedicalOrg/GetConfigFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                success: function (data) {
                    $("#form1").formSerialize(data);

                    if (data.sfxmmc && data.sfxmCode) {
                        $('#sfxmName').val(data.sfxmmc).attr('data-sfxmCode', data.sfxmCode)
                            .attr('data-sfxmmc', data.sfxmmc);
                    }
                }
            });
        }
        else {
            $('#zt').click(function () {
                return false;
            });
        }
    });

    function initControl() {
        $("#dlCode").bindSelect({
            url: "/SystemManage/SysChargeCategory/GetListJson?dllbs=2,3",
        });

        //sfxm浮层
        $('#sfxmName').sfxmFloatingSelector({
            djDecimalPlaces: 4,
            width: 350,
            ajaxparameters: function ($thisinput) {
                return "mzzybz=&dllb=2,3&dlCode=" + $('#dlCode').val() + "&keyword=" + $.trim($thisinput.val());
            },
            itemdbclickhandler: function ($thistr) {
                $('#sfxmName').attr('data-sfxmCode', $thistr.attr('data-sfxmCode'))
                    .attr('data-sfxmmc', $thistr.attr('data-sfxmmc'))
                    .val($thistr.attr('data-sfxmmc'));
            },
            colModel: [
                { label: '代码', name: 'sfxmCode', widthratio: 40 },
                { label: '名称', name: 'sfxmmc', widthratio: 40 },
                { label: '拼音', name: 'py', widthratio: 20 },
            ]
        });
    }

    function AcceptClick(callBack) {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        if ($('#sfxmName').attr('data-sfxmCode')
            && $('#sfxmName').attr('data-sfxmmc') == $('#sfxmName').val()) {
            postData['sfxmCode'] = $('#sfxmName').attr('data-sfxmCode');
        }
        $.submitForm({
            url: "/KPI/MedicalOrg/SubmitMedicalOrgPSConfig?keyValue=" + keyValue,
            param: postData,
            success: function () {
                callBack();
                $.modalClose();
            }
        })
    }
</script>